package com.example.project_out_in;

import java.util.ArrayList;
import java.util.List;

import Entities.EUsers_;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class Fragment_opption extends Fragment {
	List<EUsers_> listUser = new ArrayList<EUsers_>();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		final View root = inflater.inflate(R.layout.fragment_opption,
				container, false);
		// View v = inflater.inflate(R.layout.fragment_opption, null);
		Button btnQuanly = (Button) root.findViewById(R.id.btnQuanly);
		Button btnCustomer = (Button) root.findViewById(R.id.btnCustomer);
		Button btnChagepass = (Button) root.findViewById(R.id.btnChangepass);
		Button btnCauhinh = (Button) root.findViewById(R.id.btnCauhinh);

		Bundle extras = getActivity().getIntent().getExtras();
		EUsers_ u = new EUsers_();
		if (extras != null)
		{
			u = (EUsers_)extras.getSerializable("listUser");
			listUser.add(u);
			for (EUsers_ cn : listUser) {

				String log = "Id: "+cn.getID()+" ,Name: " + cn.getUserName() + " ,Pass: " + cn.getPassword()+" ,Chức vụ: " + cn.getRole();
				// Writing Contacts to log
				Log.d("opption : ", log);
			}
		}
		final EUsers_ uu = u;
		btnQuanly.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(root.getContext(), RegisterActivity.class);

				startActivity(i);
			}
		});

		btnCustomer.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getActivity(),
						RegisterNewActivity.class);
				startActivity(i);
			}
		});

		btnChagepass.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(root.getContext(), changePass.class);
				i.putExtra("listUser", uu);
				startActivity(i);
			}
		});

		btnCauhinh.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(root.getContext(), CamTestActivity.class);

				startActivity(i);
			}
		});
		return root;

	}

}
